<template>
  <div></div>
</template>

<script setup lang="ts">

let name: string = ''
let age: number = 1
let hasJob: boolean = true
// 不推荐大家使用，尽量少用
let anyString: any = ''

anyString = 1
anyString = '1'
anyString = []

let numberArray: string[] = [1, 2, 3, '5']

let obj: { readonly name: string; age?: number; hasJob: boolean;[key:string]:any } = {
  name: '小明',
  hasJob: true
}
obj.name = '123123'
console.log(obj)

enum Color {
  Red,//1
  Green,// 2
  Blue//3
}

Color[1]// Red
Color.Red // 1
// 枚举
enum Status{
    '禁用'=0,
    '启用'=1
}

Status[0]
 Status['禁用']

 // 函数的基本类型定义
 function test1(name:string,age:number):string{
    return `姓名为：${name},年龄为${age}`
 }

 const res = test1('1231',1)

// 函数类型的定义
let test3:(name:string,age:number) => string = (name,age) => `姓名为：${name},年龄为${age}`
test3('123',1)

// 没有任何返回
let test4:(name:string) => void = (name) => console.log(name)
test4('312')

interface Person {
    readonly name:string;
    age:number | string;
    hasJob?:boolean;
}

// 接口的继承
interface Person1 extends Person{
    type:string
}

// 接口的嵌套
interface Person4 {
    id:number;
    person:Person1;
}

const res111:Person4[]  = []
// [{id:1,person:{age:1,name:'小明'}}，{id:1,person:{age:1,name:'小明'}}]

const person211:Person4 = {}

person211.person.

const personxx:Person1 = {
    type:'1231'
}
function test5(person:Person):string{
    return `姓名：${person.name}`
}

// 定义props
</script>

<style></style>
